# NOT RUN {
# }
# NOT RUN {
#--------------
# GENERAL USE
#--------------
# Example 1
data(eco.test)
## Test with phenotypic traits (example of ?eco.correlog)
moran <- eco.correlog(Z=eco[["P"]][,1], XY = eco[["XY"]], method = "I", smax=10, size=1000)
# the slots are accesed with the generic format:
# ecoslot. + name of the slot + (name of the object)
ecoslot.OUT(moran) # slot OUT
ecoslot.BREAKS(moran) # slot BREAKS
#----------------------------------------------
# SPECIFIC USE OF ACCESSORS WITH ECOGEN OBJECTS
#----------------------------------------------
#1) GET MODE
# Example 2
# Example with G data of class "data.frame", corresponding to
# microsatellites of a diploid organism.
eco <- ecogen(XY = coordinates, P = phenotype, G = genotype,
E = environment, S = structure, order.G = TRUE)
eco
# Access to the slots
ecoslot.XY(eco)
ecoslot.P(eco)
ecoslot.G(eco)
ecoslot.A(eco)
ecoslot.E(eco)
ecoslot.S(eco)
ecoslot.C(eco)
ecoslot.OUT(eco)
# For ecogen objects, the double square brackets ("[[")
# are symbolic abbreviations of the accessors:
ecoslot.XY(eco)
# is identical to:
eco[["XY"]]
#2) SET MODE (REPLACEMENT OF SLOTS)
# Example 3
eco <- ecogen(XY = coordinates, P = phenotype)
eco
ecoslot.G(eco, order.G = TRUE) <- genotype
# this is identical to
eco[["G", order.G=TRUE]] <- genotype
ecoslot.E(eco) <- environment
ecoslot.S(eco) <- structure
# Storing the data of Example 1 in the slot OUT
ecoslot.OUT(eco) <- moran
# Storing several data
singers <- c("carlos_gardel", "billie_holiday")
golden.number <- (sqrt(5) + 1) / 2
ecoslot.OUT(eco) <- list(singers, golden.number) # several objects must be passed as a list
# In get mode, ecoslot.OUT has a double behavior:
# when only the name of the ecogen object is passed to
# the accessor, it has an overview method,
# returning a data frame with the objects
# stored and their classes
ecoslot.OUT(eco)
# ecoslot.OUT in get mode, has two arguments:
# ecoslot.OUT(object, ...)
# here, the three dots (...) means any object(s) stored in the slot OUT.
ecoslot.OUT(eco, "moran", "singers")
# In double square brackets notation, this is equivalent to
eco[["OUT"]][c("moran", "singers")]
# This is, it works as a list and have no overview method
eco[["OUT"]]
eco[["OUT"]]["moran"]
# ecoslot.OUT in set mode, has two arguments:
# ecoslot.OUT(object, value)
# here value means object(s) to store in the slot OUT. Several objects
# must be passed as a list.
# The names of the input data is recoded in case of
# duplicates
ecoslot.OUT(eco) <- singers
ecoslot.OUT(eco)
ecoslot.OUT(eco) <- list(singers, singers, singers)
ecoslot.OUT(eco)
# The set operation is equivalent with double square brackets
eco[["OUT"]] <- list(singers, c(1,2,3))
ecoslot.OUT(eco)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab